<?php
/*
 * @Author: 哲学家乔布斯 <wuyangii@qq.com>
 * @Date: 2022-10-25 20:19:21
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-10-25 20:22:43
 * @Descripttion: 
 */


namespace app\common\model;

use think\Model;

class BusWithdrawal extends Base
{
    protected $insert = ['addtime'];
    protected $state = [
        0 => '审核中',
        1 => '通过',
        2 => '拒绝',
    ];
    //---------------自动完成----------------------
    protected function setAddtimeAttr()
    {
        return time();
    }


    public function getImageTextAttr($value,$data){
        return $data['image'] ? cdnurl($data['image'],true) : "";
    }
    public function getAddtimeTextAttr($value,$data){
        return empty($data['addtime']) ? '' :  date('Y-m-d H:i:s', $data['addtime']);
    }
    public function getStateTextAttr($value,$data){
        return $this->state[$data['state']];
    }
    public function getBusTitleAttr($value,$data){
        return (new \app\common\model\Bus())->where(['id' => $data['bus_id']])->value('nickname');
    }
    public function getUserTitleAttr($value,$data){
        return (new \app\common\model\User())->where(['id' => $data['user_id']])->value('nickname');
    }
}
